FROM registry.aliyuncs.com/xiaoka/alpine-java8:1.0.1

ENV TOMCAT_MINOR_VERSION 8.0.15
ENV CATALINA_HOME /opt/tomcat

RUN apk upgrade --update && \
    apk add --update curl && \
	apk add --update unzip && \
    rm -rf /tmp/* /var/cache/apk/*

RUN curl -O http://archive.apache.org/dist/tomcat/tomcat-8/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz && \
  curl http://archive.apache.org/dist/tomcat/tomcat-8/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz.md5 | md5sum -c - && \
  gunzip apache-tomcat-*.tar.gz && \
  tar xf apache-tomcat-*.tar && \
  rm apache-tomcat-*.tar && mv apache-tomcat* ${CATALINA_HOME} && \
  rm -rf ${CATALINA_HOME}/webapps/examples \
  ${CATALINA_HOME}/webapps/docs ${CATALINA_HOME}/webapps/ROOT \
  ${CATALINA_HOME}/webapps/host-manager \
  ${CATALINA_HOME}/RELEASE-NOTES ${CATALINA_HOME}/RUNNING.txt \
  ${CATALINA_HOME}/bin/*.bat ${CATALINA_HOME}/bin/*.tar.gz

COPY server.xml /opt/tomcat/conf/
COPY scezu.jks /opt/tomcat/conf/

RUN rm -rf /opt/tomcat/webapps/manager

ADD weixin.war /opt/tomcat/webapps/ROOT.war

RUN cd /opt/tomcat/webapps/

RUN unzip -d /opt/tomcat/webapps/ROOT /opt/tomcat/webapps/ROOT.war && \
	rm -rf /opt/tomcat/webapps/ROOT.war

VOLUME /opt/tomcat/logs
VOLUME /opt/tomcat/webapps/ROOT/upload

EXPOSE 443
EXPOSE 443

EXPOSE 80
EXPOSE 80

WORKDIR /opt/tomcat

ENTRYPOINT ["/opt/tomcat/bin/catalina.sh"]
CMD [ "run" ]